"""
数据模型定义
"""

from dataclasses import dataclass
from typing import Dict, Any

@dataclass
class WeiboPost:
    """微博数据模型"""
    id: str
    text: str
    text_clean: str
    created_at: str
    reposts_count: int
    comments_count: int
    attitudes_count: int
    user_name: str
    user_id: str
    verified: bool
    pic_num: int
    source: str
    keyword: str
    crawl_time: str
    
    @property
    def total_engagement(self) -> int:
        """总互动量"""
        return self.reposts_count + self.comments_count + self.attitudes_count
    
    def to_dict(self) -> Dict[str, Any]:
        """转换为字典"""
        return {
            'id': self.id,
            'text': self.text,
            'text_clean': self.text_clean,
            'created_at': self.created_at,
            'reposts_count': self.reposts_count,
            'comments_count': self.comments_count,
            'attitudes_count': self.attitudes_count,
            'user_name': self.user_name,
            'user_id': self.user_id,
            'verified': self.verified,
            'pic_num': self.pic_num,
            'source': self.source,
            'keyword': self.keyword,
            'crawl_time': self.crawl_time,
            'total_engagement': self.total_engagement
        }